package com.kscrm.web.controller.web;

import java.util.List;
import javax.annotation.Resource;
import javax.validation.Valid;

import com.kscrm.web.dto.AddExpertDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kscrm.common.annotation.Log;
import com.kscrm.common.core.controller.BaseController;
import com.kscrm.common.core.domain.AjaxResult;
import com.kscrm.common.enums.BusinessType;
import com.kscrm.web.domain.Expert;
import com.kscrm.web.service.IExpertService;
import com.kscrm.common.core.page.TableDataInfo;

/**
 * 专家Controller
 * 
 * @author Dhq
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/web/expert")
public class ExpertController extends BaseController
{
    @Resource
    private IExpertService expertService;

    /**
     * 查询专家列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Expert expert)
    {
        startPage();
        List<Expert> list = expertService.selectExpertList(expert);
        return getDataTable(list);
    }

    /**
     * 获取专家详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(expertService.selectExpertById(id));
    }

    /**
     * 新增专家
     */
    @Log(title = "专家", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid AddExpertDto expert)
    {
        return toAjax(expertService.insertExpert(expert));
    }

    /**
     * 修改专家
     */
    @Log(title = "专家", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Expert expert)
    {
        return toAjax(expertService.updateExpert(expert));
    }

    /**
     * 删除专家
     */
    @Log(title = "专家", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(expertService.deleteExpertByIds(ids));
    }
}
